<html>
 <head>
  <meta charset="utf-8"/>
  <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport"/>
  <title>
   数据挖掘入门——分词  | 数螺 | NAUT IDEA
  </title>
  <link href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" rel="stylesheet"/>
  <link href="http://cdn.bootcss.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
  <style type="text/css">
   #xmain img {
                  max-width: 100%;
                  display: block;
                  margin-top: 10px;
                  margin-bottom: 10px;
                }

                #xmain p {
                    line-height:150%;
                    font-size: 16px;
                    margin-top: 20px;
                }

                #xmain h2 {
                    font-size: 24px;
                }

                #xmain h3 {
                    font-size: 20px;
                }

                #xmain h4 {
                    font-size: 18px;
                }


                .header {
	           background-color: #0099ff;
	           color: #ffffff;
	           margin-bottom: 20px;
	        }

	        .header p {
                  margin: 0px;
                  padding: 10px 0;
                  display: inline-block;  
                  vertical-align: middle;
                  font-size: 16px;
               }

               .header a {
                 color: white;
               }

              .header img {
                 height: 25px;
              }
  </style>
  <script src="http://cdn.bootcss.com/jquery/3.0.0/jquery.min.js">
  </script>
  <script src="http://nautstatic-10007657.file.myqcloud.com/static/css/readability.min.js" type="text/javascript">
  </script>
  <script type="text/javascript">
   $(document).ready(function() {
                 var loc = document.location;
                 var uri = {
                  spec: "http://dataunion.org/3285.html",
                  host: "http://dataunion.org",
                  prePath: "http://dataunion.org",
                  scheme: "http",
                  pathBase: "http://dataunion.org/"
                 };
    
                 var documentClone = document.cloneNode(true);
                 var article = new Readability(uri, documentClone).parse();
     
                 document.getElementById("xmain").innerHTML = article.content;
                });
  </script>
  <!-- 1466461117: Accept with keywords: (title(0.2):数据挖掘,社区,数盟,入门,分词, topn(0.266666666667):逆向,数盟,信息,中华人民共和国,情感,查找,数据挖掘,长度,赋值,数据分析,大脑,结果,知识库,分词,词库,文章,人民大会堂,数据,句子,词语,语料库,库里,语义,心情,字符串,词典,修饰词,单字,程序,识别).-->
 </head>
 <body onload="">
  <div class="header">
   <div class="container">
    <div class="row">
     <div class="col-xs-6 col-sm-6 text-left">
      <a href="/databee">
       <img src="http://nautidea-10007657.cos.myqcloud.com/logo_white.png"/>
      </a>
      <a href="/databee">
       <p>
        数螺
       </p>
      </a>
     </div>
     <div class="hidden-xs col-sm-6 text-right">
      <p>
       致力于数据科学的推广和知识传播
      </p>
     </div>
    </div>
   </div>
  </div>
  <div class="container text-center">
   <h1>
    数据挖掘入门——分词
   </h1>
  </div>
  <div class="container" id="xmain">
   ﻿﻿
   <title>
    数据挖掘入门——分词 | 数盟社区
   </title>
   <!-- All in One SEO Pack 2.2.7.6.2 by Michael Torbert of Semper Fi Web Design[32,57] -->
   <!-- /all in one seo pack -->
   <!--
<div align="center">
<a href="http://strata.oreilly.com.cn/hadoop-big-data-cn?cmp=mp-data-confreg-home-stcn16_dataunion_pc" target="_blank"><img src="http://dataunion.org/wp-content/uploads/2016/05/stratabj.jpg"/ ></a>
</div>
-->
   <header id="header-web">
    <div class="header-main">
     <hgroup class="logo">
      <h1>
       <a href="http://dataunion.org/" rel="home" title="数盟社区">
        <img src="http://dataunion.org/wp-content/themes/yzipi/images/logo.png"/>
       </a>
      </h1>
     </hgroup>
     <!--logo-->
     <nav class="header-nav">
      <ul class="menu" id="menu-%e4%b8%bb%e8%8f%9c%e5%8d%95">
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-71" id="menu-item-71">
        <a href="http://dataunion.org/category/events" title="events">
         活动
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-22457" id="menu-item-22457">
          <a href="http://dataunion.org/2016timeline">
           2016档期
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-22459" id="menu-item-22459">
          <a href="http://dataunion.org/category/parterc">
           合作会议
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category current-post-ancestor menu-item-has-children menu-item-20869" id="menu-item-20869">
        <a href="http://dataunion.org/category/tech" title="articles">
         文章
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-20867" id="menu-item-20867">
          <a href="http://dataunion.org/category/tech/base" title="base">
           基础架构
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3302" id="menu-item-3302">
          <a href="http://dataunion.org/category/tech/ai" title="ai">
           人工智能
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category current-post-ancestor current-menu-parent current-post-parent menu-item-3303" id="menu-item-3303">
          <a href="http://dataunion.org/category/tech/analysis" title="analysis">
           数据分析
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21920" id="menu-item-21920">
          <a href="http://dataunion.org/category/tech/dm">
           数据挖掘
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3314" id="menu-item-3314">
          <a href="http://dataunion.org/category/tech/viz" title="viz">
           可视化
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-3305" id="menu-item-3305">
          <a href="http://dataunion.org/category/tech/devl" title="devl">
           编程语言
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-20876" id="menu-item-20876">
        <a href="http://dataunion.org/category/industry">
         行业
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-16328" id="menu-item-16328">
          <a href="http://dataunion.org/category/industry/case" title="case">
           行业应用
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-2112" id="menu-item-2112">
          <a href="http://dataunion.org/category/industry/demo" title="demo">
           Demo展示
          </a>
         </li>
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21562" id="menu-item-21562">
          <a href="http://dataunion.org/category/industry/news">
           行业资讯
          </a>
         </li>
        </ul>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-311" id="menu-item-311">
        <a href="http://dataunion.org/category/sources" title="sources">
         资源
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-20870" id="menu-item-20870">
        <a href="http://dataunion.org/category/books" title="book">
         图书
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-21363" id="menu-item-21363">
        <a href="http://dataunion.org/category/training">
         课程
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-has-children menu-item-21853" id="menu-item-21853">
        <a href="http://dataunion.org/category/jobs">
         职位
        </a>
        <ul class="sub-menu">
         <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-22050" id="menu-item-22050">
          <a href="http://dataunion.org/category/career">
           职业规划
          </a>
         </li>
        </ul>
       </li>
      </ul>
     </nav>
     <!--header-nav-->
    </div>
   </header>
   <!--header-web-->
   <div id="main">
    <div id="soutab">
     <form action="http://dataunion.org/" class="search" method="get">
     </form>
    </div>
    <div id="container">
     <nav id="mbx">
      当前位置：
      <a href="http://dataunion.org">
       首页
      </a>
      &gt;
      <a href="http://dataunion.org/category/tech">
       文章
      </a>
      &gt;
      <a href="http://dataunion.org/category/tech/analysis">
       数据分析
      </a>
      &gt;  正文
     </nav>
     <!--mbx-->
     <article class="content">
      <header align="centre" class="contenttitle">
       <div class="mscc">
        <h1 class="mscctitle">
         <a href="http://dataunion.org/3285.html">
          数据挖掘入门——分词
         </a>
        </h1>
        <address class="msccaddress ">
         <em>
          1,598 次阅读 -
         </em>
         <a href="http://dataunion.org/category/tech/analysis" rel="category tag">
          数据分析
         </a>
        </address>
       </div>
      </header>
      <div class="content-text">
       <p>
        作者：严澜
       </p>
       <p>
        谷歌4亿英镑收购人工智能公司DeepMind，百度目前正推进“百度大脑”项目，腾讯、阿里等各大巨头也在积极布局深度学习。随着社会化数据大量产生，硬件速度上升、成本降低，大数据技术的落地实现，让冷冰冰的数据具有智慧逐渐成为新的热点。要从数据中发现有用的信息就要用到数据挖掘技术，不过买来的数据挖掘书籍一打开全是大量的数学公式，而课本知识早已还给老师了，着实难以下手、非常头大！
       </p>
       <p>
        我们不妨先跳过数学公式，看看我们了解数据挖掘的目的——发现数据中价值。这个才是关键，如何发现数据中的价值。那什么是数据呢？比如大家要上网首先需要输入网址，打开网页后会自动判断哪些是图片、哪些是新闻、哪些是用户名称、游戏图标等。大脑可以存储大量的信息，包括文字、声音、视频、图片等，这些同样可以转换成数据存储在电脑。人的大脑可以根据输入自动进行判断，电脑可以通过输入判断吗？
       </p>
       <p>
        答案是肯定的！ 不过需要我们编写程序来判断每一种信息，就拿文字识别来说吧，怎么从一个人在社交网络的言论判断他今天的心情是高兴还是愤怒！比如：“你假如上午没给我吃冰淇淋，我绝对会不happy的。”  信息发布时间为下午2点。对于我们人类一看这个句子就知道他是吃过冰淇淋了，心情肯定不会是愤怒。那计算机怎么知道呢？
       </p>
       <p>
        <b>
         这就是今天的主题，要让计算机理解句子的语义，必须要有个程序，上面的句子和发布时间是输入，输出就是 “高兴”。
        </b>
        要得到“高兴”就要建立 “高兴”的规则，可以建一个感情色彩词库，比如高兴（识别词是高兴、happy），愤怒（识别词是愤怒、生气）。这里的识别词就是输入中出现的词语，比如上面的句子中的“happy”就识别出了“高兴”这个感情色彩词。但是光识别出“happy”肯定是不行的，前面的“假如……没……，我……不……”等关键词都需要识别出来，才能完整判断一个句子的意思。为了达到这个效果，就必须要用分词技术了。
       </p>
       <h2>
        分词
       </h2>
       <p>
        我们先人工对上面的句子来进行一下切词，使用斜线分割：“你/假如/上午/没/给/我/吃/冰淇淋/，/我/绝对/会/不/happy/的/。/”。但是程序如何做到自动切分？这个其实中国的前辈们已经做了很多中文分词的研究，常见的分词算法有：
       </p>
       <p>
        <strong>
         1. 基于词典的分词
        </strong>
        ，需要先预设一个分词词典，比如上面句子切分出来的“假如、上午”这些词先存放在词典，然后把句子切分成单字组合成词语去词典里查找，匹配上了就挑选出来一个词。没有匹配上的就切分成单字。
       </p>
       <p>
        <strong>
         2. 基于统计的分词
        </strong>
        ，需要先获取大量的文本语料库（比如新闻、微博等），然后统计文本里相邻的字同时出现的次数，次数越多就越可能构成一个词。当达到一定次数时就构成了一个词，即可形成语料概率库。再对上面句子进行单字切分，把字与字结合后在语料概率库里查找对应的概率，如果概率大于一定值就挑选出来形成一个词。这个是大概描述，实际生产环境中还需要对句子的上下文进行结合才能更准确的分词。
       </p>
       <p>
        <strong>
         3. 基于语义的分词
        </strong>
        ，简而言之就是模拟人类对句子的理解来进行分词。需要先整理出中文语句的句法、语义信息作为知识库，然后结合句子的上下文，对句子进行单字切分后组合成词逐个带入知识库进行识别，识别出来就挑选出一个词。目前还没有特别成熟的基于语义的分词系统。
       </p>
       <p>
        <b>
         基于词典的分词
        </b>
       </p>
       <p>
        为了让大家快速的了解分词技术，我们采用第一个方式来做测试：基于词典的分词，这种方式简单暴力可以解决百分之七八十的问题。基于词典的分词大概分为以下几种方式：
       </p>
       <p>
        <strong>
         1. 正向最大匹配
        </strong>
        ，沿着我们看到的句子逐字拆分后组合成词语到词典里去匹配，直到匹配不到词语为止。举个实际的例子：“人民大会堂真雄伟”，我们先拆分为单字“人”去词典里去查找，发现有“人”这个词，继续组合句子里的单字组合“人民”去词典里查找，发现有“人民”这个词，以此类推发现到“人民大会堂”，然后会结合“人民大会堂真”去词典里查找没有找到这个词，第一个词“人民大会堂”查找结束。最终分词的结果为：“人民大会堂/真/雄伟”。如下图演示了用正向最大匹配算法识别人民大会堂的过程，“真”，“雄伟”的识别类似。
       </p>
       <p>
        <strong>
         2. 逆向最大匹配
        </strong>
        ，这个和上面相反，就是倒着推理。比如“沿海南方向”，我们按正向最大匹配来做就会切分成 “沿海/南方/向”，这样就明显不对。采用逆向最大匹配法则来解决这个问题，从句子的最后取得“方向”这两个字查找词典找到“方向”这个词。再加上“南方向”组成三字组合查找词典没有这个词，查找结束，找到“方向”这个词。以此类推，最终分出“沿/海南/方向”。
       </p>
       <p>
        <strong>
         3. 双向最大匹配
        </strong>
        ，顾名思义就是结合正向最大匹配和逆向最大匹配，最终取其中合理的结果。最早由哈工大王晓龙博士理论化的取最小切分词数，比如“我在中华人民共和国家的院子里看书”，正向最大匹配切分出来为“我/在/中华人民共和国/家/的/院子/里/看书”工8个词语，逆向最大匹配切分出来为“我/在/中华/人民/共/和/国家/的/院子/里/看书”共11个词语。取正向最大匹配切出来的结果就是正确的。但是如果把上面那个例子“沿海南方向”双向切分，都是3个词语，改如何选择？看第4个《最佳匹配法则》。
       </p>
       <p>
        <strong>
         4. 最佳匹配法则
        </strong>
        ，先准备一堆文本语料库、一个词库，统计词库里的每一个词在语料库里出现的次数记录下来。最后按照词频高的优先选出，比如“沿海南方向”，正向切分为：“沿海/南方/向”，逆向切分为：“沿/海南/方向”。其中“海南”的频度最高，优先取出来。剩下“沿”、“方向”也就正常切分了。是不是这就是基于词典分词的最佳方案？比如数学之美中提到的：“把手抬起来” 和 “这扇门的把手”，可以分为“把”、“手”、“把手”，不管怎么分总有一句话的意思不对。后续再介绍如何通过统计的分词处理这些问题。
       </p>
       <p>
        <a href="http://cms.csdnimg.cn/article/201409/12/5412406959899.jpg" target="_blank">
         <img src="http://cms.csdnimg.cn/article/201409/12/5412406959899_middle.jpg"/>
        </a>
       </p>
       <p>
        说了这么多，我们来实战一下如何基于词典的分词：
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57686baaceffe811371094" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          public class TestPositiveMatch {
    public static void main(String[] args) {
   String str = "我爱这个中华人民共和国大家庭";
   List&amp;lt;String&amp;gt; normalDict = new ArrayList&amp;lt;String&amp;gt;();

   normalDict.add("");
   normalDict.add("爱");
  normalDict.add("中华");  //测试词库里有中华和中华人民共和国，按照最大匹配应该匹配出中华人民共和国
   normalDict.add("中华人民共和国");

  int strLen = str.length();  //传入字符串的长度
   int j = 0;
  String matchWord = ""; //根据词库里识别出来的词
  int matchPos = 0; //根据词库里识别出来词后当前句子中的位置
  while (j &amp;lt; strLen) {  //从0字符匹配到字符串结束
  int matchPosTmp = 0;  //截取字符串的位置
   int i = 1;
  while (matchPosTmp &amp;lt; strLen) {  //从当前位置直到整句结束，匹配最大长度
   matchPosTmp = i + j;
  String keyTmp = str.substring(j, matchPosTmp);//切出最大字符串
  if (normalDict.contains(keyTmp)) { //判断当前字符串是否在词典中
  matchWord = keyTmp;  //如果在词典中匹配上了就赋值
  matchPos = matchPosTmp; //同时保存好匹配位置
   }
   i++;
   }
   if (!matchWord.isEmpty()) {
  //有匹配结果就输出最大长度匹配字符串
   j = matchPos;
  //保存位置，下次从当前位置继续往后截取
   System.out.print(matchWord + " ");
   } else {
  //从当前词开始往后都没有能够匹配上的词，则按照单字切分的原则切分
   System.out.print(str.substring(j, ++j) + " ");
   }
   matchWord = "";
   }
   }
 }
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-57686baaceffe811371094-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baaceffe811371094-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-57686baaceffe811371094-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baaceffe811371094-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-57686baaceffe811371094-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baaceffe811371094-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-57686baaceffe811371094-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baaceffe811371094-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-57686baaceffe811371094-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baaceffe811371094-10">
               10
              </div>
              <div class="crayon-num" data-line="crayon-57686baaceffe811371094-11">
               11
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baaceffe811371094-12">
               12
              </div>
              <div class="crayon-num" data-line="crayon-57686baaceffe811371094-13">
               13
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baaceffe811371094-14">
               14
              </div>
              <div class="crayon-num" data-line="crayon-57686baaceffe811371094-15">
               15
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baaceffe811371094-16">
               16
              </div>
              <div class="crayon-num" data-line="crayon-57686baaceffe811371094-17">
               17
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baaceffe811371094-18">
               18
              </div>
              <div class="crayon-num" data-line="crayon-57686baaceffe811371094-19">
               19
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baaceffe811371094-20">
               20
              </div>
              <div class="crayon-num" data-line="crayon-57686baaceffe811371094-21">
               21
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baaceffe811371094-22">
               22
              </div>
              <div class="crayon-num" data-line="crayon-57686baaceffe811371094-23">
               23
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baaceffe811371094-24">
               24
              </div>
              <div class="crayon-num" data-line="crayon-57686baaceffe811371094-25">
               25
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baaceffe811371094-26">
               26
              </div>
              <div class="crayon-num" data-line="crayon-57686baaceffe811371094-27">
               27
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baaceffe811371094-28">
               28
              </div>
              <div class="crayon-num" data-line="crayon-57686baaceffe811371094-29">
               29
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baaceffe811371094-30">
               30
              </div>
              <div class="crayon-num" data-line="crayon-57686baaceffe811371094-31">
               31
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baaceffe811371094-32">
               32
              </div>
              <div class="crayon-num" data-line="crayon-57686baaceffe811371094-33">
               33
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baaceffe811371094-34">
               34
              </div>
              <div class="crayon-num" data-line="crayon-57686baaceffe811371094-35">
               35
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baaceffe811371094-36">
               36
              </div>
              <div class="crayon-num" data-line="crayon-57686baaceffe811371094-37">
               37
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baaceffe811371094-38">
               38
              </div>
              <div class="crayon-num" data-line="crayon-57686baaceffe811371094-39">
               39
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-57686baaceffe811371094-1">
               <span class="crayon-m">
                public
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                TestPositiveMatch
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                {
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baaceffe811371094-2">
               <span class="crayon-h">
               </span>
               <span class="crayon-m">
                public
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-m">
                static
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-t">
                void
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                main
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-t">
                String
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                args
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                {
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baaceffe811371094-3">
               <span class="crayon-h">
               </span>
               <span class="crayon-t">
                String
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                str
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "我爱这个中华人民共和国大家庭"
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baaceffe811371094-4">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                List
               </span>
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                lt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-t">
                String
               </span>
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                gt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                normalDict
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                new
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                ArrayList
               </span>
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                lt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-t">
                String
               </span>
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                gt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baaceffe811371094-5">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baaceffe811371094-6">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                normalDict
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                add
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-s">
                ""
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baaceffe811371094-7">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                normalDict
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                add
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-s">
                "爱"
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baaceffe811371094-8">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                normalDict
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                add
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-s">
                "中华"
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-c">
                //测试词库里有中华和中华人民共和国，按照最大匹配应该匹配出中华人民共和国
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baaceffe811371094-9">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                normalDict
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                add
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-s">
                "中华人民共和国"
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baaceffe811371094-10">
              </div>
              <div class="crayon-line" id="crayon-57686baaceffe811371094-11">
               <span class="crayon-h">
               </span>
               <span class="crayon-t">
                int
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                strLen
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                str
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                length
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-c">
                //传入字符串的长度
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baaceffe811371094-12">
               <span class="crayon-h">
               </span>
               <span class="crayon-t">
                int
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                j
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baaceffe811371094-13">
               <span class="crayon-h">
               </span>
               <span class="crayon-t">
                String
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                matchWord
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                ""
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-c">
                //根据词库里识别出来的词
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baaceffe811371094-14">
               <span class="crayon-h">
               </span>
               <span class="crayon-t">
                int
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                matchPos
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-c">
                //根据词库里识别出来词后当前句子中的位置
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baaceffe811371094-15">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                while
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                j
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                lt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                strLen
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                {
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-c">
                //从0字符匹配到字符串结束
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baaceffe811371094-16">
               <span class="crayon-h">
               </span>
               <span class="crayon-t">
                int
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                matchPosTmp
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-c">
                //截取字符串的位置
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baaceffe811371094-17">
               <span class="crayon-h">
               </span>
               <span class="crayon-t">
                int
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                i
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baaceffe811371094-18">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                while
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                matchPosTmp
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                lt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                strLen
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                {
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-c">
                //从当前位置直到整句结束，匹配最大长度
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baaceffe811371094-19">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                matchPosTmp
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                i
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                +
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                j
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baaceffe811371094-20">
               <span class="crayon-h">
               </span>
               <span class="crayon-t">
                String
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                keyTmp
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                str
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                substring
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                j
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                matchPosTmp
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-c">
                //切出最大字符串
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baaceffe811371094-21">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                if
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                normalDict
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                contains
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                keyTmp
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                {
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-c">
                //判断当前字符串是否在词典中
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baaceffe811371094-22">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                matchWord
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                keyTmp
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-c">
                //如果在词典中匹配上了就赋值
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baaceffe811371094-23">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                matchPos
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                matchPosTmp
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-c">
                //同时保存好匹配位置
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baaceffe811371094-24">
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                }
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baaceffe811371094-25">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                i
               </span>
               <span class="crayon-o">
                ++
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baaceffe811371094-26">
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                }
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baaceffe811371094-27">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                if
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-o">
                !
               </span>
               <span class="crayon-v">
                matchWord
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                isEmpty
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                {
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baaceffe811371094-28">
               <span class="crayon-h">
               </span>
               <span class="crayon-c">
                //有匹配结果就输出最大长度匹配字符串
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baaceffe811371094-29">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                j
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                matchPos
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baaceffe811371094-30">
               <span class="crayon-h">
               </span>
               <span class="crayon-c">
                //保存位置，下次从当前位置继续往后截取
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baaceffe811371094-31">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                System
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-v">
                out
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                print
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                matchWord
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                +
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                " "
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baaceffe811371094-32">
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                }
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                else
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                {
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baaceffe811371094-33">
               <span class="crayon-h">
               </span>
               <span class="crayon-c">
                //从当前词开始往后都没有能够匹配上的词，则按照单字切分的原则切分
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baaceffe811371094-34">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                System
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-v">
                out
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                print
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                str
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                substring
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                j
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                ++
               </span>
               <span class="crayon-v">
                j
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                +
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                " "
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baaceffe811371094-35">
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                }
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baaceffe811371094-36">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                matchWord
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                ""
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baaceffe811371094-37">
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                }
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baaceffe811371094-38">
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                }
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baaceffe811371094-39">
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                }
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0127 seconds] -->
       <p>
        输出结果为：我爱这个中华人民共和国大家庭
       </p>
       <p>
        按照这样我们一个基本的分词程序开发完成。
       </p>
       <p>
        对于文章一开始提到的问题还没解决，如何让程序识别文本中的感情色彩。现在我们先要构建一个感情色彩词库“高兴”，修饰词库“没”、”不”。再完善一下我们的程序：
       </p>
       <!-- Crayon Syntax Highlighter v_2.7.2_beta -->
       <div class="crayon-syntax crayon-theme-classic crayon-font-monaco crayon-os-pc print-yes notranslate" data-settings=" minimize scroll-mouseover" id="crayon-57686baacf011979686015" style=" margin-top: 12px; margin-bottom: 12px; font-size: 12px !important; line-height: 15px !important;">
        <div class="crayon-toolbar" data-settings=" mouseover overlay hide delay" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
         <span class="crayon-title">
         </span>
         <div class="crayon-tools" style="font-size: 12px !important;height: 18px !important; line-height: 18px !important;">
          <div class="crayon-button crayon-nums-button" title="切换是否显示行编号">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-plain-button" title="纯文本显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-wrap-button" title="切换自动换行">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-expand-button" title="点击展开代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-copy-button" title="复制代码">
           <div class="crayon-button-icon">
           </div>
          </div>
          <div class="crayon-button crayon-popup-button" title="在新窗口中显示代码">
           <div class="crayon-button-icon">
           </div>
          </div>
         </div>
        </div>
        <div class="crayon-info" style="min-height: 16.8px !important; line-height: 16.8px !important;">
        </div>
        <div class="crayon-plain-wrap">
         <textarea class="crayon-plain print-no" data-settings="dblclick" readonly="" style="-moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4; font-size: 12px !important; line-height: 15px !important;" wrap="soft">
          public class TestSentimentPositiveMatch {
   public static void main(String[] args) {
   String str = "你假如上午没给我吃冰淇淋，我绝对会不happy的。";

  //语义映射
   Map&amp;lt;String, String&amp;gt; sentimentMap = new HashMap&amp;lt;String, String&amp;gt;();
   sentimentMap.put("happy", "高兴");

  //情感词库
   List&amp;lt;String&amp;gt; sentimentDict = new ArrayList&amp;lt;String&amp;gt;();
   sentimentDict.add("happy");

  //修饰词
   List&amp;lt;String&amp;gt; decorativeDict = new ArrayList&amp;lt;String&amp;gt;();
   decorativeDict.add("不");
   decorativeDict.add("没");

  //修饰词衡量分数
   Map&amp;lt;String, Double&amp;gt; decorativeScoreMap = new HashMap&amp;lt;String, Double&amp;gt;();
   decorativeScoreMap.put("不", -0.5);
   decorativeScoreMap.put("没", -0.5);

  List&amp;lt;String&amp;gt; decorativeWordList = new ArrayList&amp;lt;String&amp;gt;();  //修饰词
  String sentimentResult = ""; //情感结果

  int strLen = str.length();  //传入字符串的长度
   int j = 0;
  String matchSentimentWord = ""; //根据词库里识别出来的情感词
  String matchDecorativeWord = ""; //根据词库里识别出来的修饰词
  int matchPos = 0; //根据词库里识别出来词后当前句子中的位置
  while (j &amp;lt; strLen) {  //从0字符匹配到字符串结束
  int matchPosTmp = 0;  //截取字符串的位置
   int i = 1;
  while (matchPosTmp &amp;lt; strLen) {  //从当前位置直到整句结束，匹配最大长度
   matchPosTmp = i + j;
  String keyTmp = str.substring(j, matchPosTmp);//切出最大字符串
  if (sentimentDict.contains(keyTmp)) { //判断当前字符串是否在词典中
  matchSentimentWord = keyTmp;  //如果在词典中匹配上了就赋值
  matchPos = matchPosTmp; //同时保存好匹配位置
   }
  if (decorativeDict.contains(keyTmp)) { //判断当前字符串是否在词典中
  matchDecorativeWord = keyTmp;  //如果在词典中匹配上了就赋值
  matchPos = matchPosTmp; //同时保存好匹配位置
   }
   i++;
   }
   if (!matchSentimentWord.isEmpty()) {
  //有匹配结果就输出最大长度匹配字符串
   j = matchPos;
  //保存位置，下次从当前位置继续往后截取
   System.out.print(matchSentimentWord + " ");
   sentimentResult = sentimentMap.get(matchSentimentWord);
   }
   if (!matchDecorativeWord.isEmpty()) {
  //有匹配结果就输出最大长度匹配字符串
   j = matchPos;
  //保存位置，下次从当前位置继续往后截取
   System.out.print(matchDecorativeWord + " ");
   decorativeWordList.add(matchDecorativeWord);
   } else {
  //从当前词开始往后都没有能够匹配上的词，则按照单字切分的原则切分
   System.out.print(str.substring(j, ++j) + " ");
   }
   matchSentimentWord = "";
   matchDecorativeWord = "";
   }

   double totalScore = 1;
   for (String decorativeWord : decorativeWordList) {
   Double scoreTmp = decorativeScoreMap.get(decorativeWord);
   totalScore *= scoreTmp;
   }

   System.out.print("\r\n");
   if (totalScore &amp;gt; 0) {
   System.out.println("当前心情是：" + sentimentResult);
   } else {
   System.out.println("当前心情是：不" + sentimentResult);
   }
   }
 }
         </textarea>
        </div>
        <div class="crayon-main" style="">
         <table class="crayon-table">
          <tbody>
           <tr class="crayon-row">
            <td class="crayon-nums " data-settings="show">
             <div class="crayon-nums-content" style="font-size: 12px !important; line-height: 15px !important;">
              <div class="crayon-num" data-line="crayon-57686baacf011979686015-1">
               1
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baacf011979686015-2">
               2
              </div>
              <div class="crayon-num" data-line="crayon-57686baacf011979686015-3">
               3
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baacf011979686015-4">
               4
              </div>
              <div class="crayon-num" data-line="crayon-57686baacf011979686015-5">
               5
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baacf011979686015-6">
               6
              </div>
              <div class="crayon-num" data-line="crayon-57686baacf011979686015-7">
               7
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baacf011979686015-8">
               8
              </div>
              <div class="crayon-num" data-line="crayon-57686baacf011979686015-9">
               9
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baacf011979686015-10">
               10
              </div>
              <div class="crayon-num" data-line="crayon-57686baacf011979686015-11">
               11
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baacf011979686015-12">
               12
              </div>
              <div class="crayon-num" data-line="crayon-57686baacf011979686015-13">
               13
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baacf011979686015-14">
               14
              </div>
              <div class="crayon-num" data-line="crayon-57686baacf011979686015-15">
               15
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baacf011979686015-16">
               16
              </div>
              <div class="crayon-num" data-line="crayon-57686baacf011979686015-17">
               17
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baacf011979686015-18">
               18
              </div>
              <div class="crayon-num" data-line="crayon-57686baacf011979686015-19">
               19
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baacf011979686015-20">
               20
              </div>
              <div class="crayon-num" data-line="crayon-57686baacf011979686015-21">
               21
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baacf011979686015-22">
               22
              </div>
              <div class="crayon-num" data-line="crayon-57686baacf011979686015-23">
               23
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baacf011979686015-24">
               24
              </div>
              <div class="crayon-num" data-line="crayon-57686baacf011979686015-25">
               25
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baacf011979686015-26">
               26
              </div>
              <div class="crayon-num" data-line="crayon-57686baacf011979686015-27">
               27
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baacf011979686015-28">
               28
              </div>
              <div class="crayon-num" data-line="crayon-57686baacf011979686015-29">
               29
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baacf011979686015-30">
               30
              </div>
              <div class="crayon-num" data-line="crayon-57686baacf011979686015-31">
               31
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baacf011979686015-32">
               32
              </div>
              <div class="crayon-num" data-line="crayon-57686baacf011979686015-33">
               33
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baacf011979686015-34">
               34
              </div>
              <div class="crayon-num" data-line="crayon-57686baacf011979686015-35">
               35
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baacf011979686015-36">
               36
              </div>
              <div class="crayon-num" data-line="crayon-57686baacf011979686015-37">
               37
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baacf011979686015-38">
               38
              </div>
              <div class="crayon-num" data-line="crayon-57686baacf011979686015-39">
               39
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baacf011979686015-40">
               40
              </div>
              <div class="crayon-num" data-line="crayon-57686baacf011979686015-41">
               41
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baacf011979686015-42">
               42
              </div>
              <div class="crayon-num" data-line="crayon-57686baacf011979686015-43">
               43
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baacf011979686015-44">
               44
              </div>
              <div class="crayon-num" data-line="crayon-57686baacf011979686015-45">
               45
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baacf011979686015-46">
               46
              </div>
              <div class="crayon-num" data-line="crayon-57686baacf011979686015-47">
               47
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baacf011979686015-48">
               48
              </div>
              <div class="crayon-num" data-line="crayon-57686baacf011979686015-49">
               49
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baacf011979686015-50">
               50
              </div>
              <div class="crayon-num" data-line="crayon-57686baacf011979686015-51">
               51
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baacf011979686015-52">
               52
              </div>
              <div class="crayon-num" data-line="crayon-57686baacf011979686015-53">
               53
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baacf011979686015-54">
               54
              </div>
              <div class="crayon-num" data-line="crayon-57686baacf011979686015-55">
               55
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baacf011979686015-56">
               56
              </div>
              <div class="crayon-num" data-line="crayon-57686baacf011979686015-57">
               57
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baacf011979686015-58">
               58
              </div>
              <div class="crayon-num" data-line="crayon-57686baacf011979686015-59">
               59
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baacf011979686015-60">
               60
              </div>
              <div class="crayon-num" data-line="crayon-57686baacf011979686015-61">
               61
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baacf011979686015-62">
               62
              </div>
              <div class="crayon-num" data-line="crayon-57686baacf011979686015-63">
               63
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baacf011979686015-64">
               64
              </div>
              <div class="crayon-num" data-line="crayon-57686baacf011979686015-65">
               65
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baacf011979686015-66">
               66
              </div>
              <div class="crayon-num" data-line="crayon-57686baacf011979686015-67">
               67
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baacf011979686015-68">
               68
              </div>
              <div class="crayon-num" data-line="crayon-57686baacf011979686015-69">
               69
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baacf011979686015-70">
               70
              </div>
              <div class="crayon-num" data-line="crayon-57686baacf011979686015-71">
               71
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baacf011979686015-72">
               72
              </div>
              <div class="crayon-num" data-line="crayon-57686baacf011979686015-73">
               73
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baacf011979686015-74">
               74
              </div>
              <div class="crayon-num" data-line="crayon-57686baacf011979686015-75">
               75
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baacf011979686015-76">
               76
              </div>
              <div class="crayon-num" data-line="crayon-57686baacf011979686015-77">
               77
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baacf011979686015-78">
               78
              </div>
              <div class="crayon-num" data-line="crayon-57686baacf011979686015-79">
               79
              </div>
              <div class="crayon-num crayon-striped-num" data-line="crayon-57686baacf011979686015-80">
               80
              </div>
              <div class="crayon-num" data-line="crayon-57686baacf011979686015-81">
               81
              </div>
             </div>
            </td>
            <td class="crayon-code">
             <div class="crayon-pre" style="font-size: 12px !important; line-height: 15px !important; -moz-tab-size:4; -o-tab-size:4; -webkit-tab-size:4; tab-size:4;">
              <div class="crayon-line" id="crayon-57686baacf011979686015-1">
               <span class="crayon-m">
                public
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-t">
                class
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                TestSentimentPositiveMatch
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                {
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baacf011979686015-2">
               <span class="crayon-h">
               </span>
               <span class="crayon-m">
                public
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-m">
                static
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-t">
                void
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-e">
                main
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-t">
                String
               </span>
               <span class="crayon-sy">
                [
               </span>
               <span class="crayon-sy">
                ]
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                args
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                {
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baacf011979686015-3">
               <span class="crayon-h">
               </span>
               <span class="crayon-t">
                String
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                str
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "你假如上午没给我吃冰淇淋，我绝对会不happy的。"
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baacf011979686015-4">
              </div>
              <div class="crayon-line" id="crayon-57686baacf011979686015-5">
               <span class="crayon-h">
               </span>
               <span class="crayon-c">
                //语义映射
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baacf011979686015-6">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                Map
               </span>
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                lt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-t">
                String
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-t">
                String
               </span>
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                gt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                sentimentMap
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                new
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                HashMap
               </span>
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                lt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-t">
                String
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-t">
                String
               </span>
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                gt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baacf011979686015-7">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                sentimentMap
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                put
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-s">
                "happy"
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                "高兴"
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baacf011979686015-8">
              </div>
              <div class="crayon-line" id="crayon-57686baacf011979686015-9">
               <span class="crayon-h">
               </span>
               <span class="crayon-c">
                //情感词库
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baacf011979686015-10">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                List
               </span>
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                lt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-t">
                String
               </span>
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                gt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                sentimentDict
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                new
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                ArrayList
               </span>
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                lt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-t">
                String
               </span>
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                gt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baacf011979686015-11">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                sentimentDict
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                add
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-s">
                "happy"
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baacf011979686015-12">
              </div>
              <div class="crayon-line" id="crayon-57686baacf011979686015-13">
               <span class="crayon-h">
               </span>
               <span class="crayon-c">
                //修饰词
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baacf011979686015-14">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                List
               </span>
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                lt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-t">
                String
               </span>
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                gt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                decorativeDict
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                new
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                ArrayList
               </span>
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                lt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-t">
                String
               </span>
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                gt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baacf011979686015-15">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                decorativeDict
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                add
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-s">
                "不"
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baacf011979686015-16">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                decorativeDict
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                add
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-s">
                "没"
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baacf011979686015-17">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baacf011979686015-18">
               <span class="crayon-h">
               </span>
               <span class="crayon-c">
                //修饰词衡量分数
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baacf011979686015-19">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                Map
               </span>
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                lt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-t">
                String
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-t">
                Double
               </span>
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                gt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                decorativeScoreMap
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                new
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                HashMap
               </span>
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                lt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-t">
                String
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-t">
                Double
               </span>
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                gt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baacf011979686015-20">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                decorativeScoreMap
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                put
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-s">
                "不"
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-cn">
                0.5
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baacf011979686015-21">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                decorativeScoreMap
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                put
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-s">
                "没"
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                -
               </span>
               <span class="crayon-cn">
                0.5
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baacf011979686015-22">
              </div>
              <div class="crayon-line" id="crayon-57686baacf011979686015-23">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                List
               </span>
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                lt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-t">
                String
               </span>
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                gt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                decorativeWordList
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-r">
                new
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                ArrayList
               </span>
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                lt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-t">
                String
               </span>
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                gt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-c">
                //修饰词
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baacf011979686015-24">
               <span class="crayon-h">
               </span>
               <span class="crayon-t">
                String
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                sentimentResult
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                ""
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-c">
                //情感结果
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baacf011979686015-25">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baacf011979686015-26">
               <span class="crayon-h">
               </span>
               <span class="crayon-t">
                int
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                strLen
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                str
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                length
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-c">
                //传入字符串的长度
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baacf011979686015-27">
               <span class="crayon-h">
               </span>
               <span class="crayon-t">
                int
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                j
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baacf011979686015-28">
               <span class="crayon-h">
               </span>
               <span class="crayon-t">
                String
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                matchSentimentWord
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                ""
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-c">
                //根据词库里识别出来的情感词
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baacf011979686015-29">
               <span class="crayon-h">
               </span>
               <span class="crayon-t">
                String
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                matchDecorativeWord
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                ""
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-c">
                //根据词库里识别出来的修饰词
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baacf011979686015-30">
               <span class="crayon-h">
               </span>
               <span class="crayon-t">
                int
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                matchPos
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-c">
                //根据词库里识别出来词后当前句子中的位置
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baacf011979686015-31">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                while
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                j
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                lt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                strLen
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                {
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-c">
                //从0字符匹配到字符串结束
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baacf011979686015-32">
               <span class="crayon-h">
               </span>
               <span class="crayon-t">
                int
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                matchPosTmp
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-c">
                //截取字符串的位置
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baacf011979686015-33">
               <span class="crayon-h">
               </span>
               <span class="crayon-t">
                int
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                i
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baacf011979686015-34">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                while
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                matchPosTmp
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                lt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                strLen
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                {
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-c">
                //从当前位置直到整句结束，匹配最大长度
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baacf011979686015-35">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                matchPosTmp
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                i
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                +
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                j
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baacf011979686015-36">
               <span class="crayon-h">
               </span>
               <span class="crayon-t">
                String
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                keyTmp
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                str
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                substring
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                j
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                matchPosTmp
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-c">
                //切出最大字符串
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baacf011979686015-37">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                if
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                sentimentDict
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                contains
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                keyTmp
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                {
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-c">
                //判断当前字符串是否在词典中
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baacf011979686015-38">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                matchSentimentWord
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                keyTmp
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-c">
                //如果在词典中匹配上了就赋值
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baacf011979686015-39">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                matchPos
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                matchPosTmp
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-c">
                //同时保存好匹配位置
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baacf011979686015-40">
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                }
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baacf011979686015-41">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                if
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                decorativeDict
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                contains
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                keyTmp
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                {
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-c">
                //判断当前字符串是否在词典中
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baacf011979686015-42">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                matchDecorativeWord
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                keyTmp
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-c">
                //如果在词典中匹配上了就赋值
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baacf011979686015-43">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                matchPos
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                matchPosTmp
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-c">
                //同时保存好匹配位置
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baacf011979686015-44">
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                }
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baacf011979686015-45">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                i
               </span>
               <span class="crayon-o">
                ++
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baacf011979686015-46">
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                }
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baacf011979686015-47">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                if
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-o">
                !
               </span>
               <span class="crayon-v">
                matchSentimentWord
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                isEmpty
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                {
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baacf011979686015-48">
               <span class="crayon-h">
               </span>
               <span class="crayon-c">
                //有匹配结果就输出最大长度匹配字符串
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baacf011979686015-49">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                j
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                matchPos
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baacf011979686015-50">
               <span class="crayon-h">
               </span>
               <span class="crayon-c">
                //保存位置，下次从当前位置继续往后截取
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baacf011979686015-51">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                System
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-v">
                out
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                print
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                matchSentimentWord
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                +
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                " "
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baacf011979686015-52">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                sentimentResult
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                sentimentMap
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                get
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                matchSentimentWord
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baacf011979686015-53">
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                }
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baacf011979686015-54">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                if
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-o">
                !
               </span>
               <span class="crayon-v">
                matchDecorativeWord
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                isEmpty
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                {
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baacf011979686015-55">
               <span class="crayon-h">
               </span>
               <span class="crayon-c">
                //有匹配结果就输出最大长度匹配字符串
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baacf011979686015-56">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                j
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                matchPos
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baacf011979686015-57">
               <span class="crayon-h">
               </span>
               <span class="crayon-c">
                //保存位置，下次从当前位置继续往后截取
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baacf011979686015-58">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                System
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-v">
                out
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                print
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                matchDecorativeWord
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                +
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                " "
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baacf011979686015-59">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                decorativeWordList
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                add
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                matchDecorativeWord
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baacf011979686015-60">
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                }
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                else
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                {
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baacf011979686015-61">
               <span class="crayon-h">
               </span>
               <span class="crayon-c">
                //从当前词开始往后都没有能够匹配上的词，则按照单字切分的原则切分
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baacf011979686015-62">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                System
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-v">
                out
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                print
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                str
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                substring
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                j
               </span>
               <span class="crayon-sy">
                ,
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                ++
               </span>
               <span class="crayon-v">
                j
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                +
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                " "
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baacf011979686015-63">
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                }
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baacf011979686015-64">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                matchSentimentWord
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                ""
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baacf011979686015-65">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                matchDecorativeWord
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-s">
                ""
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baacf011979686015-66">
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                }
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baacf011979686015-67">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baacf011979686015-68">
               <span class="crayon-h">
               </span>
               <span class="crayon-t">
                double
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                totalScore
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                1
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baacf011979686015-69">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                for
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-t">
                String
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                decorativeWord
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                :
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                decorativeWordList
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                {
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baacf011979686015-70">
               <span class="crayon-h">
               </span>
               <span class="crayon-t">
                Double
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                scoreTmp
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                decorativeScoreMap
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                get
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                decorativeWord
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baacf011979686015-71">
               <span class="crayon-h">
               </span>
               <span class="crayon-e ">
                totalScore *
               </span>
               <span class="crayon-o">
                =
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                scoreTmp
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baacf011979686015-72">
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                }
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baacf011979686015-73">
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baacf011979686015-74">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                System
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-v">
                out
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                print
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-s">
                "\r\n"
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baacf011979686015-75">
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                if
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-v">
                totalScore
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                &amp;
               </span>
               <span class="crayon-v">
                gt
               </span>
               <span class="crayon-sy">
                ;
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-cn">
                0
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                {
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baacf011979686015-76">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                System
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-v">
                out
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                println
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-s">
                "当前心情是："
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                +
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                sentimentResult
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baacf011979686015-77">
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                }
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-st">
                else
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                {
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baacf011979686015-78">
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                System
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-v">
                out
               </span>
               <span class="crayon-sy">
                .
               </span>
               <span class="crayon-e">
                println
               </span>
               <span class="crayon-sy">
                (
               </span>
               <span class="crayon-s">
                "当前心情是：不"
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-o">
                +
               </span>
               <span class="crayon-h">
               </span>
               <span class="crayon-v">
                sentimentResult
               </span>
               <span class="crayon-sy">
                )
               </span>
               <span class="crayon-sy">
                ;
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baacf011979686015-79">
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                }
               </span>
              </div>
              <div class="crayon-line crayon-striped-line" id="crayon-57686baacf011979686015-80">
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                }
               </span>
              </div>
              <div class="crayon-line" id="crayon-57686baacf011979686015-81">
               <span class="crayon-h">
               </span>
               <span class="crayon-sy">
                }
               </span>
              </div>
             </div>
            </td>
           </tr>
          </tbody>
         </table>
        </div>
       </div>
       <!-- [Format Time: 0.0243 seconds] -->
       <p>
        通过传入“你假如上午没给我吃冰淇淋，我绝对会不happy的。”，结果输出为：“当前心情是：高兴”。当然你也可以改变其中的修饰词，比如改为：“你假如上午没给我吃冰淇淋，我绝对会happy的。”，结果输出为：“当前心情是：不高兴”。
       </p>
       <p>
        机器再也不是冷冰冰的，看起来他能读懂你的意思了。不过这只是一个开始，抛出几个问题：
       </p>
       <ol>
        <li>
         如何让程序识别句子中的时间？比如“上午”、“下午2点”。
        </li>
        <li>
         如何处理“把手抬起来” 和 “这扇门的把手”中的“把”与“手”的问题？
        </li>
        <li>
         如何构建海量的知识库，让程序从“婴儿”变成“成年人”？
        </li>
        <li>
         如何使用有限的存储空间存储海量的知识库？
        </li>
        <li>
         如何提高程序在海量知识库中查找定位信息的效率？
        </li>
        <li>
         如何识别新词、人名、新鲜事物等未知领域？
        </li>
       </ol>
       <p>
        宇宙芸芸众生都是相通的，大脑也许就是一个小宇宙，在这个小宇宙又有很多星球、住着很多生物。而电脑也是宇宙中地球上的一个产物，只要存储计算速度发展到足够强大一定可以构建成一个强大的大脑。
       </p>
       <p>
        你看这个单词 “testaword” 认识吗？可能不认识，因为我们五官先获取到的信息，然后根据大脑以往学习的经验做出判断。但是你看这个短语 ” test a word” 认识吗？再看看开始那个单词“testaword”是不是就亲切多了？
       </p>
       <p>
       </p>
       <p>
        文章出处：CSDN
       </p>
      </div>
      <div>
       <strong>
        注：转载文章均来自于公开网络，仅供学习使用，不会用于任何商业用途，如果侵犯到原作者的权益，请您与我们联系删除或者授权事宜，联系邮箱：contact@dataunion.org。转载数盟网站文章请注明原文章作者，否则产生的任何版权纠纷与数盟无关。
       </strong>
      </div>
      <!--content_text-->
      <div class="fenxian">
       <!-- JiaThis Button BEGIN -->
       <div class="jiathis_style_32x32">
        <p class="jiathis_button_weixin">
        </p>
        <p class="jiathis_button_tsina">
        </p>
        <p class="jiathis_button_qzone">
        </p>
        <p class="jiathis_button_cqq">
        </p>
        <p class="jiathis_button_tumblr">
        </p>
        <a class="jiathis jiathis_txt jtico jtico_jiathis" href="http://www.jiathis.com/share" target="_blank">
        </a>
        <p class="jiathis_counter_style">
        </p>
       </div>
       <!-- JiaThis Button END -->
      </div>
     </article>
     <!--content-->
     <!--相关文章-->
     <div class="xianguan">
      <div class="xianguantitle">
       相关文章！
      </div>
      <ul class="pic">
       <li>
        <a href="http://dataunion.org/20824.html">
         <img src="http://dataunion.org/wp-content/uploads/2015/09/t018630756a7e263b33-300x165.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/20824.html" rel="bookmark" title="如何判断一笔交易是否属于欺诈？你只是需要一点数据挖掘">
         如何判断一笔交易是否属于欺诈？你只是需要一点数据挖掘
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/20679.html">
         <img src="http://dataunion.org/wp-content/uploads/2015/09/t010e3a70fbcfef2c12-300x101.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/20679.html" rel="bookmark" title="一篇文章带你认识“高大上”的图数据挖掘">
         一篇文章带你认识“高大上”的图数据挖掘
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/20167.html">
         <img src="http://dataunion.org/wp-content/uploads/2015/07/t0170189d0bb57172e9_副本.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/20167.html" rel="bookmark" title="浅谈金融行业的数据挖掘之道">
         浅谈金融行业的数据挖掘之道
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/19877.html">
         <img src="http://dataunion.org/wp-content/uploads/2015/07/t01d360f079b2c02f4d.jpg"/>
        </a>
        <a class="link" href="http://dataunion.org/19877.html" rel="bookmark" title="想入门机器学习、数据挖掘，我该怎么做？">
         想入门机器学习、数据挖掘，我该怎么做？
        </a>
       </li>
      </ul>
     </div>
     <!--相关文章-->
     <div class="comment" id="comments">
      <!-- You can start editing here. -->
      <!-- If comments are open, but there are no comments. -->
      <div class="title">
       期待你一针见血的评论，Come on！
      </div>
      <div id="respond">
       <p>
        不用想啦，马上
        <a href="http://dataunion.org/wp-login.php?redirect_to=http%3A%2F%2Fdataunion.org%2F3285.html">
         "登录"
        </a>
        发表自已的想法.
       </p>
      </div>
     </div>
     <!-- .nav-single -->
    </div>
    <!--Container End-->
    <aside id="sitebar">
     <div class="sitebar_list2">
      <div class="wptag">
       <span class="tagtitle">
        热门标签+
       </span>
       <div class="tagg">
        <ul class="menu" id="menu-%e5%8f%8b%e6%83%85%e9%93%be%e6%8e%a5">
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-1605" id="menu-item-1605">
          <a href="http://taidizh.com/">
           泰迪智慧
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-20884" id="menu-item-20884">
          <a href="http://www.transwarp.cn/">
           星环科技
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-3538" id="menu-item-3538">
          <a href="http://datall.org/">
           珈和遥感
          </a>
         </li>
         <li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-20888" id="menu-item-20888">
          <a href="http://www.chinahadoop.cn/">
           小象学院
          </a>
         </li>
        </ul>
       </div>
      </div>
     </div>
     <div class="sitebar_list">
      <div class="textwidget">
       <div align="center">
        <a href="http://study.163.com/course/courseMain.htm?courseId=991022" target="_blank">
         <img src="http://dataunion.org/wp-content/uploads/2016/03/dv.jpg"/>
        </a>
       </div>
      </div>
     </div>
     <div class="sitebar_list">
      <h4 class="sitebar_title">
       文章分类
      </h4>
      <div class="tagcloud">
       <a class="tag-link-44" href="http://dataunion.org/category/industry/demo" style="font-size: 10.204724409449pt;" title="4个话题">
        Demo展示
       </a>
       <a class="tag-link-31" href="http://dataunion.org/category/experts" style="font-size: 15.826771653543pt;" title="52个话题">
        专家团队
       </a>
       <a class="tag-link-870" href="http://dataunion.org/category/tech/ai" style="font-size: 19.795275590551pt;" title="273个话题">
        人工智能
       </a>
       <a class="tag-link-488" href="http://dataunion.org/category/%e5%8a%a0%e5%85%a5%e6%95%b0%e7%9b%9f" style="font-size: 8pt;" title="1个话题">
        加入数盟
       </a>
       <a class="tag-link-869" href="http://dataunion.org/category/tech/viz" style="font-size: 17.204724409449pt;" title="93个话题">
        可视化
       </a>
       <a class="tag-link-30" href="http://dataunion.org/category/partners" style="font-size: 10.645669291339pt;" title="5个话题">
        合作伙伴
       </a>
       <a class="tag-link-889" href="http://dataunion.org/category/parterc" style="font-size: 11.582677165354pt;" title="8个话题">
        合作会议
       </a>
       <a class="tag-link-104" href="http://dataunion.org/category/books" style="font-size: 12.96062992126pt;" title="15个话题">
        图书
       </a>
       <a class="tag-link-220" href="http://dataunion.org/category/tech/base" style="font-size: 19.850393700787pt;" title="281个话题">
        基础架构
       </a>
       <a class="tag-link-219" href="http://dataunion.org/category/tech/analysis" style="font-size: 19.409448818898pt;" title="232个话题">
        数据分析
       </a>
       <a class="tag-link-887" href="http://dataunion.org/category/tech/dm" style="font-size: 13.291338582677pt;" title="17个话题">
        数据挖掘
       </a>
       <a class="tag-link-34" href="http://dataunion.org/category/tech" style="font-size: 20.732283464567pt;" title="404个话题">
        文章
       </a>
       <a class="tag-link-1" href="http://dataunion.org/category/uncategorized" style="font-size: 22pt;" title="693个话题">
        未分类
       </a>
       <a class="tag-link-4" href="http://dataunion.org/category/events" style="font-size: 14.503937007874pt;" title="29个话题">
        活动
       </a>
       <a class="tag-link-890" href="http://dataunion.org/category/tech/%e6%b7%b1%e5%ba%a6%e5%ad%a6%e4%b9%a0" style="font-size: 10.204724409449pt;" title="4个话题">
        深度学习
       </a>
       <a class="tag-link-221" href="http://dataunion.org/category/tech/devl" style="font-size: 18.968503937008pt;" title="193个话题">
        编程语言
       </a>
       <a class="tag-link-888" href="http://dataunion.org/category/career" style="font-size: 15.661417322835pt;" title="48个话题">
        职业规划
       </a>
       <a class="tag-link-5" href="http://dataunion.org/category/jobs" style="font-size: 14.11811023622pt;" title="25个话题">
        职位
       </a>
       <a class="tag-link-871" href="http://dataunion.org/category/industry" style="font-size: 15.716535433071pt;" title="49个话题">
        行业
       </a>
       <a class="tag-link-613" href="http://dataunion.org/category/industry/case" style="font-size: 16.984251968504pt;" title="84个话题">
        行业应用
       </a>
       <a class="tag-link-885" href="http://dataunion.org/category/industry/news" style="font-size: 17.425196850394pt;" title="102个话题">
        行业资讯
       </a>
       <a class="tag-link-10" href="http://dataunion.org/category/training" style="font-size: 14.228346456693pt;" title="26个话题">
        课程
       </a>
       <a class="tag-link-16" href="http://dataunion.org/category/sources" style="font-size: 15.661417322835pt;" title="48个话题">
        资源
       </a>
      </div>
     </div>
     <div class="sitebar_list">
      <h4 class="sitebar_title">
       功能
      </h4>
      <ul>
       <li>
        <a href="http://dataunion.org/wp-login.php?action=register">
         注册
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/wp-login.php">
         登录
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/feed">
         文章
         <abbr title="Really Simple Syndication">
          RSS
         </abbr>
        </a>
       </li>
       <li>
        <a href="http://dataunion.org/comments/feed">
         评论
         <abbr title="Really Simple Syndication">
          RSS
         </abbr>
        </a>
       </li>
       <li>
        <a href="https://cn.wordpress.org/" title="基于WordPress，一个优美、先进的个人信息发布平台。">
         WordPress.org
        </a>
       </li>
      </ul>
     </div>
    </aside>
    <div class="clear">
    </div>
   </div>
   <!--main-->
   ﻿
   <footer id="dibu">
    <div class="about">
     <div class="right">
      <ul class="menu" id="menu-%e5%ba%95%e9%83%a8%e8%8f%9c%e5%8d%95">
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-18024" id="menu-item-18024">
        <a href="http://dataunion.org/category/partners">
         合作伙伴
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-20881" id="menu-item-20881">
        <a href="http://dataunion.org/contribute">
         文章投稿
        </a>
       </li>
       <li class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-20872" id="menu-item-20872">
        <a href="http://dataunion.org/category/%e5%8a%a0%e5%85%a5%e6%95%b0%e7%9b%9f">
         加入数盟
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-22441" id="menu-item-22441">
        <a href="http://dataunion.org/f-links">
         友情链接
        </a>
       </li>
       <li class="menu-item menu-item-type-post_type menu-item-object-page menu-item-20874" id="menu-item-20874">
        <a href="http://dataunion.org/aboutus">
         关于数盟
        </a>
       </li>
      </ul>
      <p class="banquan">
       数盟社区        ，
        做最棒的数据科学社区
      </p>
     </div>
     <div class="left">
      <ul class="bottomlist">
       <li>
        <a href="http://weibo.com/DataScientistUnion  " target="_blank" 　title="">
         <img src="http://dataunion.org/wp-content/themes/yzipi/images/weibo.png"/>
        </a>
       </li>
       <li>
        <a class="cd-popup-trigger" href="http://dataunion.org/3285.html#0">
         <img src="http://dataunion.org/wp-content/themes/yzipi/images/weixin.png"/>
        </a>
       </li>
      </ul>
      <div class="cd-popup">
       <div class="cd-popup-container">
        <h1>
         扫描二维码,加微信公众号
        </h1>
        <img src="http://dataunion.org/wp-content/themes/yzipi/images/2014-12-06-1515289049.png"/>
        <a class="cd-popup-close" href="http://dataunion.org/3285.html">
        </a>
       </div>
       <!-- cd-popup-container -->
      </div>
      <!-- cd-popup -->
     </div>
    </div>
    <!--about-->
    <div class="bottom">
     <a href="http://dataunion.org/">
      数盟社区
     </a>
     <a href="http://www.miitbeian.gov.cn/" rel="external nofollow" target="_blank">
      京ICP备14026740号
     </a>
     联系我们：
     <a href="mailto:contact@dataunion.org" target="_blank">
      contact@dataunion.org
     </a>
     <div class="tongji">
     </div>
     <!--bottom-->
     <div class="scroll" id="scroll" style="display:none;">
      ︿
     </div>
    </div>
   </footer>
   <!--dibu-->
  </div>
 </body>
</html>